package middle;

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Solution_253 {

    public static void main(String[] args) {
        Solution_253 model = new Solution_253();
    }

    public int minMeetingRooms(int[][] intervals) {
        Arrays.sort(intervals, Comparator.comparingInt(a -> a[0]));
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        queue.add(intervals[0][1]);
        int count = 1;
        for (int i = 1; i < intervals.length; i++) {
            if (intervals[i][0] < queue.peek()) {
                count++;
            } else {
                queue.poll();
            }
            queue.add(intervals[i][1]);
        }
        return count;
    }
}
